<script setup lang="ts">
//GoodsDetail  展示商品详情信息

import { useGoodsStore } from "@/stores/GoodsStore";

//GoodsComment  展示商品评价信息
const active = ref<"GoodsDetail" | "GoodsComment">("GoodsDetail");
//获取用于存储商品信息的store
const goodsStore = useGoodsStore();
</script>
<template>
  <div class="goods-tabs">
    <nav>
      <a
        :class="{ active: active === 'GoodsDetail' }"
        href="javascript:"
        @click="active = 'GoodsDetail'"
        >商品详情</a
      >
      <a
        @click="active = 'GoodsComment'"
        :class="{ active: active === 'GoodsComment' }"
        href="javascript:"
        >商品评价<span
          >({{ goodsStore.evaluateInfo.result.evaluateCount }})</span
        ></a
      >
    </nav>
    <!-- 切换内容的地方 -->
    <GoodsDetail v-show="active === 'GoodsDetail'" />
    <GoodsComment v-show="active === 'GoodsComment'" />
  </div>
</template>

<style lang="less" scoped>
.goods-tabs {
  min-height: 600px;
  background: #fff;
  nav {
    height: 70px;
    line-height: 70px;
    display: flex;
    border-bottom: 1px solid #f5f5f5;
    a {
      padding: 0 40px;
      font-size: 18px;
      position: relative;
      > span {
        color: @priceColor;
        font-size: 16px;
        margin-left: 10px;
      }
      &:first-child {
        border-right: 1px solid #f5f5f5;
      }
      &.active {
        &::before {
          content: "";
          position: absolute;
          left: 40px;
          bottom: -1px;
          width: 72px;
          height: 2px;
          background: @xtxColor;
        }
      }
    }
  }
}
</style>
